/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package elektra.facebook;

import com.restfb.Connection;
import com.restfb.DefaultFacebookClient;
import com.restfb.FacebookClient;
import com.restfb.Parameter;
import com.restfb.WebRequestor;
import com.restfb.types.Page;
import com.restfb.types.Post;
import com.restfb.types.User;

/**
 *
 * @author adee
 */
public class FacebookSpider {
    public static String access_token= "AAACEdEose0cBAKeNz23uvB19IpQN8NvAZCpOL4NjbZCWKADY7nSZAZCZATK6RqSh6Kxif7e3vCPyoK5zvuO3tKRKX0o3QZBu68jEhxBRVvsgZDZD";

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        FacebookClient facebookClient = new DefaultFacebookClient(access_token);

        User user = facebookClient.fetchObject("me", User.class);
        
        Page page = facebookClient.fetchObject("cocacola", Page.class);
        System.out.println("User name: " + user.getName());
        
        Connection<User> myFriends = facebookClient.fetchConnection("me/friends", User.class);

        
        for (User friend: myFriends.getData()){
            System.out.println( friend.getId());  
            
            Connection<Post> myFeed = facebookClient.fetchConnection(friend.getId()+"/feed", Post.class);
            
             for(Post post: myFeed.getData()){
               System.out.println("+++++"+post.getMessage());
               System.out.println("LINK:"+post.getLink() );
               System.out.println("ID:"+post.getObjectId() );
             }
            
        }
 
   //     Connection<Post> myFeed = facebookClient.fetchConnection("", Post.class);

        
   //     System.out.println("Count of my friends: " + myFriends.getData().size());
  //      System.out.println("First item in my feed: " + myFeed.getData().get(0).getMessage());
        
        
   //     for(Post post: myFeed.getData()){
   //          System.out.println("+++++"+post.getMessage());
   //          System.out.println("LINK:"+post.getLink() );
   //          System.out.println("ID:"+post.getObjectId() );
    //    }

       
    }
}
